class Student(object):
    @property
    def score(self):
        return 'score = ' + str(self._score)

    @score.setter
    def score(self, value):
        if not isinstance(value, int):
            raise ValueError('score must be an integer!')
        if value < 0 or value > 100:
            raise ValueError('score must between 0 ~ 100!')
        self._score = value

    def __str__(self):
        return 'student info: ' + self.score

    def __getattr__(self, item):
        if item == 'address':
            return 'china'
        elif item == 'attr_fun':
            return lambda x: x * x

s = Student()
s.score = 60
print(s.score) # score = 60
print(s.address) # china
print(s.attr_fun(4)) # 16
print(s) # student info: score = 60
s.score = 999 # 抛出异常
